package cn.shengchao.examstar.rpc.base;

import cn.hutool.json.JSONObject;

import java.io.Serializable;
import java.util.List;

public class PageResult<T> implements Serializable {
    private int total;        // 总记录数
    private List<T> list;  // 当前页数据
    private JSONObject extensions; //扩展字段

    public static <U> PageResult<U> of(Long total, List<U> page) {
        PageResult<U> pageResult = new PageResult<>();
        pageResult.setTotal(total.intValue());
        pageResult.setList(page);
        return pageResult;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public JSONObject getExtensions() {
        return extensions;
    }

    public void setExtensions(JSONObject extensions) {
        this.extensions = extensions;
    }
}
